<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>选项卡</title>
</head>
<style>
    body,
    div,
    ul,
    ol,
    li {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    body {
        position: relative;
    }

    .news {
        width: 500px;
        height: 500px;
        position: absolute;
        left: 50vw;
        top: 50vh;
        transform: translate(-50%, -50%);
        display: flex;
        flex-direction: column;
    }

    .news ul {
        width: 100%;
        display: flex;
    }

    .news ul li {
        flex-grow: 1;
        border: solid black 1px;
        background-color: #b2b2b3;
        font-size: 30px;
        height: 80px;
        text-align: center;
        line-height: 80px;
        cursor: pointer;
    }

    .news ol {
        flex-grow: 1;
        position: relative;
    }

    .news ol li {
        width: 100%;
        height: 100%;
        font-size: 100px;
        display: none;
        justify-content: center;
        align-items: center;
        position: absolute;
        top: 0;
        left: 0;
    }

    .news ol li:nth-of-type(1) {
        background-color: #00a0ff;
    }

    .news ol li:nth-of-type(2) {
        background-color: #f15a23;
    }

    .news ol li:nth-of-type(3) {
        background-color: #f5a2c0;
    }

    .news ul li.active {
        background-color: #fff;
        border-bottom-color: #fff;
    }

    .news ol li.active {
        display: flex;
    }
</style>

<body>
    <div class="news">
        <ul>
            <li class="active">标题1</li>
            <li>标题2</li>
            <li>标题3</li>
        </ul>
        <ol>
            <li class="active">内容1</li>
            <li>内容2</li>
            <li>内容3</li>
        </ol>
    </div>
    <script>
        let title = document.querySelectorAll("ul li")
        let content = document.querySelectorAll("ol li")
        title.forEach((item, key) => {
            item.onclick = function () {
                content.forEach((item2, key2) => {
                    content[key2].className = ''
                    title[key2].className = ''
                })
                item.className = 'active'
                content[key].className = 'active'
            }
        });
    </script>
</body>

</html>